﻿using System;
using IterationLife.ContentResources.Models;
using IterationLife.Extensions.Helpers;
using Util;

namespace IterationLife.Mobile.AppServices.Dtos.Common
{
    /// <summary>
    /// 内容资源评论[输出]
    /// </summary>
    public class ContentResourceCommentOutPut
    {
        /// <summary>
        /// 用户名
        /// </summary>
        public string UserName { get; set; }

        /// <summary>
        /// 内容
        /// </summary>
        public string Content { get; set; }

        /// <summary>
        /// 时间
        /// </summary>
        public string Time { get; set; }

        /// <summary>
        /// 排序号
        /// </summary>
        public int? SortId { get; set; }
    }

    /// <summary>
    /// 内容资源评论评论[输出]扩展
    /// </summary>
    public static class ContentResourceCommentOutPutExtension
    {
        /// <summary>
        /// 转换为内容资源评论[输出]
        /// </summary>
        /// <param name="entity">内容资源评论</param>
        public static ContentResourceCommentOutPut ToNewsCommentOutPut(this ContentResourceComment entity)
        {
            return new ContentResourceCommentOutPut
            {
                UserName = entity.UserName,
                Content = entity.Content,
                Time = TimeHelper.IntervalDescription(entity.CreationTime.SafeValue(), DateTime.Now),
                SortId = entity.SortId
            };
        }
    }

}
